/*
    Copyright © 2014-2019 by The qTox Project Contributors

    This file is part of qTox, a Qt-based graphical interface for Tox.

    qTox is libre software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    qTox is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with qTox.  If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "contact.h"
#include "../core/core.h"
#include "../core/extension.h"
#include "../core/toxid.h"
#include "../core/contactid.h"
#include "status.h"

#include "signal.hpp"

class Friend : public Contact
{
public:
    Friend(uint32_t friendId, const ToxPk& friendPk, const std::string& userAlias = {}, const std::string &userName = {});
    Friend(const Friend& other) = delete;
    Friend& operator=(const Friend& other) = delete;

    void setName(const std::string& name) override;
    void setAlias(const std::string& name);
    std::string getDisplayedName() const override;
    bool hasAlias() const;
    std::string getUserName() const;
    void setStatusMessage(const std::string& message);
    std::string getStatusMessage() const;

    void setEventFlag(bool f) override;
    bool getEventFlag() const override;

    const ToxPk& getPublicKey() const;
    uint32_t getId() const override;
    const ContactId& getPersistentId() const override;

    void finishNegotiation();
    void setStatus(Status::Status s);
    Status::Status getStatus() const;
    bool useHistory() const final;

    void setExtendedMessageSupport(bool supported);
    ExtensionSet getSupportedExtensions() const;

//signals:
    sigslot::signal<const ToxPk& , const std::string& > nameChanged;
    sigslot::signal<const ToxPk& , std::string > aliasChanged;
    sigslot::signal<const ToxPk& , Status::Status > statusChanged;
    sigslot::signal<const ToxPk& , bool > onlineOfflineChanged;
    sigslot::signal<const ToxPk& , const std::string& > statusMessageChanged;
    sigslot::signal<ExtensionSet > extensionSupportChanged;
    sigslot::signal<> loadChatHistory;

//public slots:
    void onNegotiationComplete();
private:
    std::string userName;
    std::string userAlias;
    std::string statusMessage;
    ToxPk friendPk;
    uint32_t friendId;
    bool hasNewEvents;
    Status::Status friendStatus;
    bool isNegotiating;
    ExtensionSet supportedExtensions;
};
